package com.boat.ai.advice;

import jakarta.inject.Inject;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;
import org.jboss.logging.Logger;

@Provider
public class GlobalExceptionHandler implements ExceptionMapper<Exception> {

    @Inject
    Logger log;
    @Override
    public Response toResponse(Exception ex) {
        log.infof(ex, "错误信息：" + ex.getMessage());
        return Response.status(500)
                      .entity("错误信息：" + ex.getMessage())
                      .build();
    }
}
